From: Juri Linkov Date: Sat, 18 Jul 2009 21:05:47 +0000 (+0000) Subject: (process-kill-buffer-query-function): New function. X-Git-Tag: archive/raspbian/1%29.2+1-2+rpi1~1^2~324^2~11407 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=7a464f911ebf3c109e5e92d2c095a9cfddd2c5a5;p=emacs.git (process-kill-buffer-query-function): New function. (add-hook): Add hook `process-kill-buffer-query-function'. --- diff --git a/lisp/subr.el b/lisp/subr.el index 777202cf1ee..37411bcb8ad 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1722,6 +1722,16 @@ Value is t if a query was formerly required." (set-process-query-on-exit-flag process nil) old)) +(defun process-kill-buffer-query-function () + "Ask before killing a buffer that has a running process." + (let ((process (get-buffer-process (current-buffer)))) + (or (not process) + (not (memq (process-status process) '(run stop open listen))) + (not (process-query-on-exit-flag process)) + (yes-or-no-p "Buffer has a running process; kill it? ")))) + +(add-hook 'kill-buffer-query-functions 'process-kill-buffer-query-function) + ;; process plist management (defun process-get (process propname)